﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.Reputation.Tests.FrontEndCommon
{
    public partial class ReputationCategory
    {
        public int CategoryId { get; set; }
        public int Confidence { get; set; }
        public bool HostInheritance { get; set; }
        public bool PathInheritance { get; set; }

        public bool AssertEquals(ReputationCategory other)
        {
            Assert.AreEqual(CategoryId, other.CategoryId, "The categoryId fields don't match");
            Assert.AreEqual(Confidence, other.Confidence, "The confidence fields don't match");
            Assert.AreEqual(HostInheritance, other.HostInheritance, "The host inheritance fields don't match");
            Assert.AreEqual(PathInheritance, other.PathInheritance, "The path inheritance fields don't match");

            return true;
        }

        public override bool Equals(object obj)
        {
            ReputationCategory rc = obj as ReputationCategory;
            if (rc != null 
                && rc.CategoryId == this.CategoryId 
                && rc.Confidence == this.Confidence
                && rc.HostInheritance == this.HostInheritance 
                && rc.PathInheritance == this.PathInheritance 
                )
            {
                return true;
            }

            return false;
        }

        public override string ToString()
        {
            return string.Format("{0}:{1}:{2}:{3}", CategoryId, Confidence, Convert.ToInt32(HostInheritance), Convert.ToInt32(PathInheritance));
        }

        public override int GetHashCode()
        {
            int hash = 0;

            hash ^= this.CategoryId;
            hash ^= this.Confidence;
            hash ^= Convert.ToInt32(this.HostInheritance);
            hash ^= Convert.ToInt32(this.PathInheritance);
            
            return hash;
        }
    }
}
